package com.sina.shop.util;

import com.sina.cloudstorage.services.scs.SCS;

import java.net.URL;
import java.util.Date;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * 段浩杰   2018-01-10-16:36
 */
public class SinaCloudUrlUtils {

    private static final String SHOP_PHOTO = "finance-documents";


    public static String getBaseUrl(String photoUrl, SCS conn) {

        Date expiration = new Date();       //过期时间
        long epochMillis = expiration.getTime();
        epochMillis += 60 * 5 * 1000;
        expiration = new Date(epochMillis);

        URL presignedUrl = conn.generatePresignedUrl(SHOP_PHOTO, photoUrl, expiration, false);
        System.out.println(presignedUrl);
        return presignedUrl.toString();
    }
}
